$(document).ready(function(){
	searchHotsale();
});

function searchHotsale(){
	$('#tableid').DataTable({
        dom: '<"top">rt<"bottom"flip><"clear">',
        language: {
            "sUrl":'../static/plugins/datatables/language.json'
        },
        "searching": false,
        "processing": true,
        "serverSide": true,
        ajax:{
            url:'/goods-hot-sale/get-hot-sale',
            type:'post',
            data:function(d){
            },
            error:getError
        },
        aoColumns: [
            { "data": "", "bSortable": false},
            { "data": "id", "bSortable": true},
            { "data": "hot_sale_name", "bSortable": false },
            { "data": "sort", "bSortable": true },
            { "data": "memo", "bSortable": false },
            { "data": "platform", "bSortable": false },
            { "data": "use_flg", "bSortable":false }
        ],
        columnDefs: [
            {
                "targets": [0],
                "orderable":false,
                "searchable":false,
                "render": function(data, type, full) {
                    return '<a href="javascript:" onclick="changeHotSaleGoods('+ full.id +',\''+full.hot_sale_name+'\',\''+full.sort+'\',\''+full.memo+'\',\''+full.platform+'\',\''+full.use_flg+'\')">修改</a>';
                }
            },
            {
                "targets": [1],
                "orderable":false,
                "searchable":false,
                "render": function(data, type, full) {
                    return full.id;
                }
            },
            {
                "targets": [5],
                "orderable":false,
                "searchable":false,
                "render": function(data, type, full) {
                	return data == 1 ? 'pc' : 'wap';
                }
            },
            {
                "targets": [6],
                "data": "use_flg",
                "render": function(data, type, full) {
                	return '<span class="switch" data-id="'+ full.id +'" data-flg="'+(data == 1 ? 0 : 1)+'"><input  style="width:20px;height:20px;" type="checkbox" '+(data == 1 ? 'checked="checked"' : '')+' class="input-check"></span>';
                    //return '<a href="javascript:" class="'+(data == 1 ? 'text-danger' : '')+'" onclick="changeHotGoodsStatus('+ full.id +','+(data == 1 ? 0 : 1)+')">'+(data == 1 ? '禁用' : '启用')+'</a>';
                }
            }
        ],
        order: [[ 3, "asc"]]
    });
}

function changeHotSaleGoods(id,hot_sale_name,sort,memo,platform,use_flg){
	$.post('/goods-hot-sale/get-hot-sale-detail',{id:id,platform:platform},success,'json');
	function success(data){
		$('#hot-sale-modal').modal('show');
		$("#hot_sale_id").val(id);
		$('#platform').val(platform);
    	$('#hot_sale_name').val(hot_sale_name);
    	$('#sort').val(sort);
    	$('#use_flg').val(use_flg);
    	if(memo != '' && memo != 'null'){
    		$('#memo').val(memo);
    	}
    	$('#input_table').find('tbody').html('');
    	$('#input_table_sku').find('tbody').html('');
    	$('#input_table_category').find('tbody').html('');
    	$('#input_table_sku_go').find('tbody').html('');
    	if(data.code == 200){
    		var result = data.val;
    		if(platform == '1'){
    			$('.type_pc').removeClass('hide');
    			$('.type_wap').addClass('hide');
                if(result != '' && result != null && result.length > 0){
                	for(var i=0;i<result.length;i++){
                		var html = '';
                		var class_len = $('#class_len').val();
                    	var div_class = 'dropdown-sin-'+class_len;
                    	html += '<tr>';
                    	html += '<td><div class="'+div_class+'">';
                    	html += '<select name="sku[]" class="form-control">';
                    	html += '<option value="0">请选择</option>';
                    	html += '<option selected value="'+result[i].sku+'">'+result[i].sku+'</option>';
                    	html += '</select>';
                    	html += '</div></td>';
                    	html += '<td><input name="picture_name[]" value="'+result[i].picture_name+'" class="form-control"><input type="hidden" name="banner_config_id[]" value="'+result[i].id+'"></td>';
                        html += '<td><input name="picture_alt[]" value="'+result[i].picture_alt+'" class="form-control"></td>';
                    	html += '<td><button type="button" class="btn btn-success depart-modal upload-img-btn-main" style="width: 100px;">上传</button><input name="picture_url[]" value="'+result[i].picture_url+'" class="form-control" type="hidden"></td>';
                		if(result[i].picture_url){
                			html += '<td><button onclick="showImg(\''+result[i].picture_url+'\')" type="button" class="btn btn-success depart-modal show-img-btn">查看图片</button></td>';
                		}else{
                			html += '<td></td>';
                    	}
                    	html += '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a> <a class="del_input_table_tr" href="javascript:;">删除</a></td>';
                    	html += '</tr>';
                    	$('#input_table').find('tbody').append(html);
                        $('.'+div_class).dropdown({
                            readOnly: true,
                            input: '<input type="text" maxLength="20" placeholder="请输入搜索">'
                     	});
                    	class_len++;
                    	$('#class_len').val(class_len);
                   	}
                }
    		}else{
    			$('.type_pc').addClass('hide');
    			$('.type_wap').removeClass('hide');
    			var sku = result.sku;
    			var category_list = result.category;
    			var sku_go = result.sku_go;
    			if(sku != '' && sku != null && sku.length > 0){
                	for(var i=0;i<sku.length;i++){
                		var html = '';
                		var class_len = $('#class_len').val();
                		var div_class = 'dropdown-sin-'+class_len;
                		var html = '<tr><td><input name="sku[]" value="'+sku[i].sku+'" class="form-control"><input type="hidden" name="banner_config_id_sku[]" value="'+sku[i].id+'"></td>';
                			html += '<td>'+sku[i].goods_name_cn+'</td>';
                	    	html += '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a> <a class="del_input_table_tr" href="javascript:;">删除</a></td></tr>';
                	    $('#input_table_sku').find('tbody').append(html);
                    	class_len++;
                    	$('#class_len').val(class_len);
                    	
                   	}
                }
    			if(category_list != '' && category_list != null && category_list.length > 0){
    				for(var i=0;i<category_list.length;i++){
    					var class_len = $('#class_len').val();
            			var div_class = 'dropdown-sin-'+class_len;
            			var html = '<tr><td><input type="hidden" name="banner_config_id_category[]" value="'+category_list[i].id+'">';
            				html += '<div class="'+div_class+'">';
            			 	html += '<select style="display:none" name="category[]" placeholder="请选择">';
            			 	for(key in category){
            			 		html += '<option value="'+key+'" '+(key == category_list[i].category_id ? 'selected' : '')+'>'+category[key]+'</option>';
            			 	}
            				html += '</select>';
            				html += '</div>';
            				html += '</td>';
            				html += '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a> <a class="del_input_table_tr" href="javascript:;">删除</a></td></tr>';
            			    $('#input_table_category').find('tbody').append(html);
            			    $('.'+div_class).dropdown({
            			    	readOnly: true,
            			        input: '<input type="text" maxLength="20" placeholder="请输入搜索">'
            			    });
            		    class_len++;
            		    $('#class_len').val(class_len);
    				}
    			}
    			for(var i=0;i<4;i++){
    				var sku,goods_name_cn;
    				if(sku_go == undefined){
    					id = 0;
    					sku = '';
    					goods_name_cn = '';
    				}else{
    					id = sku_go[i].id;
    					sku = sku_go[i].sku;
    					goods_name_cn = sku_go[i].goods_name_cn;
    				}
	    		    var class_len = $('#class_len').val();
	    			var div_class = 'dropdown-sin-'+class_len;
	    			var html = '';
	    			html += '<tr>';
    		    	html += '<td><input name="banner_config_id_go[]" value="'+id+'" type="hidden"><div class="'+div_class+'">';
    		    	html += '<select name="sku_go[]" class="form-control">';
    		    	html += '<option value="0">请选择</option>';
    		    	if(sku){
    		    		html += '<option value="'+sku+'" selected>'+sku+'</option>';
    		    	}
    		    	html += '</select>';
    		    	html += '</div></td>';
    		    	html += '<td>'+goods_name_cn+'</td>'+
    		        '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a></td>'+
    		        '</tr>';
	    		    $('#input_table_sku_go').find('tbody').append(html);
	    		    $('.'+div_class).dropdown({
	    		        readOnly: true,
	    		        input: '<input type="text" maxLength="20" placeholder="请输入搜索">'
	    		 	});
	    			class_len++;
	    			$('#class_len').val(class_len);
	    			$('.dropdown-option').on('click',function(){
	    		    	var sku = $(this).attr('data-value');
	    		    	validateSku(sku,$(this),'go');
	    		    });
				}
    		}
        }else{
        	$.jBox.error(data.val, '错误');
        }
    }
}

function changeHotGoodsStatus(id,use_flg){
	title = '确定禁用此热销组吗？';
	if(use_flg == 1){
		title = '确定启用此热销组吗？';
	}
	$.jBox.confirm(title, "提示", function(v){
        if (v == 'ok'){
            $.post('/goods-hot-sale/change-hot-sale-status',{id:id,use_flg:use_flg},success,'json');
            return false;
            function success(data){
                $.jBox.close();
                if(data.code == 200)
                {
                    $.jBox.tip('处理成功', 'success');
                    window.setTimeout(function () { table_list_reload(); }, 1000);
                }
                else{
                    $.jBox.error(data.val, '错误');
                }
            }
        }else{
        	if(use_flg == 1){
        		$('#tableid').find('span[data-id='+id+']').children('input').prop('checked',false);
        	}else{
        		$('#tableid').find('span[data-id='+id+']').children('input').prop('checked',true);
        	}
            $.jBox.close();
        }
    });
}

function table_list_reload(){
    var table = $('#tableid').DataTable();
    table.ajax.reload();
}

function showImg(img_url){
	if(img_url == '' || img_url == null || img_url == undefined){
        $.jBox.error('数据为空', '错误');
        return false;
    }
	var json = {
        "title": "分类图片", //相册标题
        "id": 0, //相册id
        "start": 0, //初始显示的图片序号，默认0
        "data": [   //相册包含的图片，数组格式
            {
                "alt": "",//图片名
                "pid": 0, //图片id
                "src": $('#imageBathUrl').val() + img_url, //原图地址
                "thumb": "" //缩略图地址
            }
        ]
    };
    layer.photos({
        photos: json
    });
}

$('#add_input').click(function(){
	var class_len = $('#class_len').val();
	var div_class = 'dropdown-sin-'+class_len;
    var html = '<tr>';
    	html += '<td><div class="'+div_class+'">';
    	html += '<select name="sku[]" class="form-control">';
    	html += '<option value="0">请选择</option>';
    	if(sale_edit.length > 0){
    		sale_edit.forEach(function(e,index){
    			html += '<option value="'+e.sku+'">'+e.sku+'</option>';
    		});
    	}
    	html += '</select>';
    	html += '</div></td>';
    	html += '<td><input name="picture_name[]" class="form-control"><input name="banner_config_id[]" value="0" type="hidden"></td>'+
        '<td><input name="picture_alt[]" class="form-control"></td>'+
        '<td><button type="button" class="btn btn-success depart-modal upload-img-btn-main" style="width: 100px;">上传</button><input type="hidden" name="picture_url[]" class="form-control"></td>'+
        '<td></td>'+
        '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a> <a class="del_input_table_tr" href="javascript:;">删除</a></td>'+
        '</tr>';
    $('#input_table').find('tbody').append(html);
    $('.'+div_class).dropdown({
        readOnly: true,
        input: '<input type="text" maxLength="20" placeholder="请输入搜索">'
 	});
	class_len++;
	$('#class_len').val(class_len);
});

$('#add_input_sku').click(function(){
	var class_len = $('#class_len').val();
	var div_class = 'dropdown-sin-'+class_len;
	var html = '<tr><td><input name="sku[]" value="" class="form-control"><input type="hidden" name="banner_config_id_sku[]" value="0"></td>';
		html += '<td></td>';
    	html += '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a> <a class="del_input_table_tr" href="javascript:;">删除</a></td></tr>';
    $('#input_table_sku').find('tbody').append(html);
    $('.'+div_class).dropdown({
        readOnly: true,
        input: '<input type="text" maxLength="20" placeholder="请输入搜索">'
	});
    class_len++;
    $('#class_len').val(class_len);
    $('#input_table_sku').find('input[name="sku[]"]').blur(function(){
    	var where = $(this);
		var sku = where.val();
		validateSku(sku,where);
	});
});

$('#add_input_category').click(function(){
	var class_len = $('#class_len').val();
	var div_class = 'dropdown-sin-'+class_len;
	var html = '<tr><td><input type="hidden" name="banner_config_id_category[]" value="0">';
		html += '<div class="'+div_class+'">';
	 	html += '<select style="display:none" name="category[]" placeholder="请选择">';
	 	for(key in category){
	 		html += '<option value="'+key+'">'+category[key]+'</option>';
	 	}
		html += '</select>';
		html += '</div>';
		html += '</td>';
		html += '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a> <a class="del_input_table_tr" href="javascript:;">删除</a></td></tr>';
	    $('#input_table_category').find('tbody').append(html);
	    $('.'+div_class).dropdown({
	    	readOnly: true,
	        input: '<input type="text" maxLength="20" placeholder="请输入搜索">'
	    });
    class_len++;
    $('#class_len').val(class_len);
});

$('.add-hot-sale').click(function(){
	$('#hot-sale-modal').modal('show');
	$('#platform').val('1');
	$('.type_pc').removeClass('hide');
	$('.type_wap').addClass('hide');
	$("#hot_sale_id").val('');
	$('#hot_sale_name').val('');
	$('#memo').val('');
	$('#sort').val('');
	$('#use_flg').val(0);
    $('#input_table').find('tbody').html('');
    $('#input_table_sku_go').find('tbody').html('');
    var class_len = $('#class_len').val();
	var div_class = 'dropdown-sin-'+class_len;
	var html = '';
	for(var i=0;i<4;i++){
		html += '<tr><td><input name="banner_config_id_go[]" value="0" type="hidden"><div class="'+div_class+'">';
    	html += '<select name="sku_go[]" class="form-control">';
    	html += '<option value="0">请选择</option>';
    	if(sale_edit.length > 0){
    		sale_edit.forEach(function(e,index){
    			html += '<option value="'+e.sku+'">'+e.sku+'</option>';
    		});
    	}
    	html += '</select>';
    	html += '</div></td>';
    	html += '<td></td>'+
        '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a></td>'+
        '</tr>';
	}
    $('#input_table_sku_go').find('tbody').append(html);
    $('.'+div_class).dropdown({
        readOnly: true,
        input: '<input type="text" maxLength="20" placeholder="请输入搜索">'
 	});
	class_len++;
	$('#class_len').val(class_len);
    $('#input_table_category').find('tbody').html('');
    $('#input_table_sku').find('tbody').html('');
    $('.dropdown-option').on('click',function(){
    	var sku = $(this).attr('data-value');
    	validateSku(sku,$(this),'go');
    });
});

$('#platform').on('change',function(){
	if($(this).val() == 1){
		$('.type_pc').removeClass('hide');
		$('.type_wap').addClass('hide');
	}else{
		$('#input_table_sku_go').find('tbody').html('');
	    var class_len = $('#class_len').val();
		var div_class = 'dropdown-sin-'+class_len;
		var html = '';
		for(var i=0;i<4;i++){
			html += '<tr>';
	    	html += '<td><input name="banner_config_id_go[]" value="0" type="hidden"><div class="'+div_class+'">';
	    	html += '<select name="sku_go[]" class="form-control">';
	    	html += '<option value="0">请选择</option>';
	    	if(sale_edit.length > 0){
	    		sale_edit.forEach(function(e,index){
	    			html += '<option value="'+e.sku+'">'+e.sku+'</option>';
	    		});
	    	}
	    	html += '</select>';
	    	html += '</div></td>';
	    	html += '<td></td>'+
	        '<td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a></td>'+
	        '</tr>';
		}
	    $('#input_table_sku_go').find('tbody').append(html);
	    $('.'+div_class).dropdown({
	        readOnly: true,
	        input: '<input type="text" maxLength="20" placeholder="请输入搜索">'
	 	});
		class_len++;
		$('#class_len').val(class_len);
	    $('.dropdown-option').on('click',function(){
	    	var sku = $(this).attr('data-value');
	    	validateSku(sku,$(this),'go');
	    });
		$('.type_pc').addClass('hide');
		$('.type_wap').removeClass('hide');
	}
});

$('.upload-img-btn').click(function(){
    $('.upload_file').trigger('click');
});

$('.upload_file').change(function(){
	$('#upload_form_update_excel').submit();
});

$('#upload_form_update_excel').submit(function(e){
    e.preventDefault();
    $.ajaxFileUpload({
		url: '/goods-hot-sale/excel-file-upload',
		secureuri: false,
		fileElementId: 'file',
		dataType: 'json',
		success: function (data, status){
			if (data.code == 200) {
				$('#input_table_sku').find('tbody').html('');
				var result = data.val;
				result.forEach(function(data,index){
					var html = '';
					html += '<tr class="'+data.sku+'">';
					html += '<td><input name="sku[]" value="'+data.sku+'" class="form-control"><input name="banner_config_id_sku[]" value="0" type="hidden"></td>';
					html += '<td></td><td><a href="javascript:;" class="up_input_table_tr">上移</a> <a href="javascript:;" class="down_input_table_tr">下移</a> <a class="del_input_table_tr" href="javascript:;">删除</a></td>';
					html += '</tr>';
					$('#input_table_sku').find('tbody').append(html);
					where = $('.'+data.sku).find('input[name="sku[]"]');
					validateSku(data.sku,where);
				});
				$('#input_table_sku').find('input[name="sku[]"]').blur(function(){
	            	var where = $(this);
	        		var sku = where.val();
	        		validateSku(sku,where);
	        	});
			} else {
				$.jBox.error(data.val, '错误');
			}
		},
		error: function (data, status, e){
			$.jBox.error(status, '错误');
		}
	});
});

function validateSku(sku,where,type){
	if(sku == '' || sku == undefined){
		return false;
	}
	$.post('/activity-message/validate-sku',{sku:sku},success,'json');
	function success(data){
    	if(data.code == 200){
    		if(type == 'go'){
    			where.parents('td').next().text(data.val);
    		}else{
    			where.parent().next().text(data.val);
    		}
        }else{
        	$.jBox.error(data.val, '错误');
        }
    }
}

$('table').delegate('.del_input_table_tr','click',function(){
    $(this).parents('tr').remove();
});

$('table').delegate('.up_input_table_tr','click',function(){
    var tr_index = $(this).parents('tr').index();
    if(eval(tr_index) == 0){
        return true;
    }else{
        var obj = $(this).parents('tr').clone();
        $(this).parents('tr').prev().before(obj);
        $(this).parents('tr').remove();
    }
});

$('table').delegate('.down_input_table_tr','click',function(){
    var tr_index = $(this).parents('tr').next().index();
    if(eval(tr_index) > eval(-1)){
        var obj = $(this).parents('tr').clone();
        $(this).parents('tr').next().after(obj);
        $(this).parents('tr').remove();
    }
});

$('table').delegate('.upload-img-btn-main','click',function(){
	var len = $(this).parents('tr').index();
	$('#check_img_val').val(len);
    $('.upload_file_ot').trigger('click');
});

$('.upload_file_ot').change(function(){
    if(this.value != ''){
    	$('#upload_form_update').submit();
    }
});

$('#upload_form_update').submit(function(e){
    e.preventDefault();
    $(this).ajaxSubmit({
        success:function(data){
            var result = $.parseJSON(data);
            if(result.code == 500){
                $.jBox.error(result.val, '错误');
            }else{
            	var len = $('#check_img_val').val();
                var i=0;
            	$('.tbody-class').find('tr').each(function(){
            		if(eval(len) == eval(i)){
            			$(this).find('input[name="picture_url[]"]').val(result.val);
            			var viewpic = '<button onclick="showImg(\''+result.val+'\')" type="button" class="btn btn-success depart-modal show-img-btn">查看图片</button>';
            			$(this).find('.upload-img-btn-main').parent().next('td').html(viewpic);
            		}
                	i++;
                });
            	$('input[type=file]').closest('form').get(0).reset();
            }
        }
    });
});

$('.ajax_post_tag').click(function(){
	var form = $('#hot_sale_form');
    var hot_sale_name = $('#hot_sale_name').val();
    if(hot_sale_name == ''){
        $.jBox.error('请输入热销组名称', '错误');
        return false;
    }
    var sort = $('#sort').val();
    if(sort == ''){
        $.jBox.error('请输入热销组排序编号', '错误');
        return false;
    }
    var tr_num = $('.tbody-class').children('tr').length;
    if(tr_num == 0){
    	$.jBox.error('至少填写一个热销商品', '错误');
        return false;
    }
    if($('#platform').val() == '2'){
    	var error_count = 0;
        $('select[name="sku_go[]"]').each(function(){
        	if($(this).val() == '0'){
        		error_count++;
        	}
        });
        if(error_count > 0){
        	$.jBox.error('请选择首页限时抢GO商品', '错误');
            return false;
        }
    }
    $.post(form.attr('action'),form.serialize(),success,'json');
    return false;
	function success(data){
        if(data.code == 200)
        {
            $.jBox.tip('处理成功', 'success');
            window.setTimeout(function () {
                $('#hot-sale-modal').modal('hide');
                table_list_reload();
            }, 1000);
        }
        else{
            $.jBox.error(data.val, '错误');
        }
	}
});

$('table').on('click','.input-check',function(){
	var id = $(this).parent().attr('data-id');
	var use_flg = $(this).parent().attr('data-flg');
	changeHotGoodsStatus(id,use_flg);
});

//$('#input_table').on('keyup','input[placeholder="请输入搜索"]',function(){
//	var sku = $(this).val();
//	var where = $(this);
//	$.post('/goods-hot-sale/select-sale-sku',{sku:sku},success,'json');
//	return false;
//	function success(data){
//		if(data.code == 200)
//        {
//			var html = '<option selected="" value="0">请选择</option>';
//			var html_div = '<li tabindex="0" data-value="0" class="dropdown-option">请选择</li>';
//            var result = data.val;
//            if(result.length > 0){
//            	result.forEach(function(e,index){
//        			html += '<option value="'+e.sku+'">'+e.sku+'</option>';
//        			html_div += '<li tabindex="0" data-value="'+e.sku+'" class="dropdown-option">'+e.sku+'</li>';
//        		});
//            }
//            var new_where = $(where).parents('td').find('select');
//            new_where.html(html);
//            $(where).parent().parent().find('ul').html(html_div);
//        }
//        else{
//            $.jBox.error(data.val, '错误');
//        }
//	}
//});

$('#input_table,#input_table_sku_go').on('keyup','input[placeholder="请输入搜索"]',function(){
	var sku = $(this).val();
	var where = $(this);
	$.post('/goods-hot-sale/select-sale-sku',{sku:sku},success,'json');
	return false;
	function success(data){
		if(data.code == 200)
        {
			var id_val = where.parents('table').attr('id');
			var class_len = $('#class_len').val();
			var div_class = 'dropdown-sin-'+class_len;
            var result = data.val;
            var html = '<input name="banner_config_id_go[]" value="0" type="hidden">';
            if(id_val == 'input_table'){
            	html += '<div class="'+div_class+'"><select name="sku[]" class="form-control"><option value="0">请选择</option>';
            }else{
            	html += '<div class="'+div_class+'"><select name="sku_go[]" class="form-control"><option value="0">请选择</option>';
            }
            if(result.length > 0){
            	result.forEach(function(e,index){
        			html += '<option value="'+e.sku+'">'+e.sku+'</option>';
        		});
            }
            html += '</select></div>';
            var new_where = $(where).parents('td');
            new_where.html(html);
            $('.'+div_class).dropdown({
                readOnly: true,
                input: '<input type="text" value="'+sku+'" maxLength="20" placeholder="请输入搜索">'
         	});
        	class_len++;
        	$('#class_len').val(class_len);
        	$('.'+div_class).addClass('active');
        	if(id_val == 'input_table_sku_go'){
        		$('.dropdown-option').on('click',function(){
    		    	var sku = $(this).attr('data-value');
    		    	validateSku(sku,$(this),'go');
    		    });
        	}
        }
        else{
            $.jBox.error(data.val, '错误');
        }
	}
});